<template>
  <div id="container" v-if="flag"></div>
</template>

<script>
import AMapLoader from '@amap/amap-jsapi-loader'
// import { getMap } from '@/api/map'


export default {
  name: '',
  props: {
     locationHouse:{
      type:Array,
     }
  },
  components: {},
  data () {
    return {
      map: null,
      location: [],
      renderList: [],
      flag: false,
    }
  },
  methods: {
    async initMap () {
      const AMap = await AMapLoader.load({
        key: 'c2d58d1a48dc656eb931da16f8fdf422', // 申请好的Web端开发者Key，首次调用 load 时必填
        version: '2.0', // 指定要加载的 JSAPI 的版本，缺省时默认为 1.4.15
        plugins: ['AMap.PlaceSearch', 'AMap.AutoComplete', 'AMap.Geocoder'] // 需要使用的的插件列表，如比例尺'AMap.Scale'等
      })
  
      this.map = new AMap.Map('container', {
        //设置地图容器id
        // viewMode:"3D",    //是否为3D地图模式
        zoom: 12, //初始化地图级别
        center: this.location //初始化地图中心点位置
      })

    },
  //   mapClick(value,a){
  //  console.log(value);
  //  console.log(a);
  //     }
  },

  async created () {
   this.location.push(this.locationHouse.longitude)
   this.location.push(this.locationHouse.latitude)
    this.flag = true
  },

  mounted () {
    this.initMap()
  },

}
</script>

<style scoped lang="less">
#container {
  padding: 0;
  margin: 0;
  width: 100%;
  height: 145px;
}

</style>
